#include <Servo.h>     // includes the servo libs
Servo LeftServo;       // name the servo
Servo RightServo;      // name the servo

void setup(){
   //pinMode(7,???):   // For the ping sensor, not sure if it's declaired here.
   pinMode(8,OUTPUT);
   pinMode(9,OUTPUT); 
   LeftServo.attach(8);	 // Attaches the Left Servo to PWM pin 6 on the Arduino
   RightServo.attach(9); // Attaches the Right Servo to PWM pin 5 on the Arduino
   
  Serial.begin(9600);                 // Sets the baud rate to 9600
  // int ultraSoundSignal = 7;           // Ultrasound signal pin

}

  
void moveServoLeftTo(int angle, int duration){
  // command the servo to move to the given angle for the given number of milliseconds  
   LeftServo.write(angle);		
   for( ; duration > 0; duration -= 20){  // loop for the given number of milliseconds by subtracting 20ms each iteration
	 LeftServo.refresh();             // call the service routine to move the servo 
	 delay(20);		          // wait 20 milliseconds  between each refresh 
   }
}
void moveServoRightTo(int angle, int duration){
  // command the servo to move to the given angle for the given number of milliseconds  
   RightServo.write(angle);		
   for( ; duration > 0; duration -= 20){  // loop for the given number of milliseconds by subtracting 20ms each iteration
	 RightServo.refresh();            // call the service routine to move the servo 
	 delay(20);		          // wait 20 milliseconds  between each refresh 
   }  

}
void loop() {
  
	moveServoLeftTo(90,200);   // move the left servo to 45 degrees for 500 milliseconds
	moveServoRightTo(90,200);  // moveRightTo function is left as an excercise ;) 
}  
